﻿@{
    ViewData["Title"] = "添加用户";
    Layout = "_Edit";
}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add" style="padding-right:80px">
        <input type="hidden" class="input-text" value="@Model.UserID" placeholder="" id="userID" name="userID">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                @if (@Model.UserID > 0)
                {
                    <input type="text" class="input-text" readonly value="@Model.UserName" placeholder="" id="userName" name="userName">
                }
                else
                {
                    <input type="text" class="input-text" value="@Model.UserName" placeholder="" id="userName" name="userName">
                }
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.FullName" placeholder="" id="fullName" name="fullName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>部门：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Department" placeholder="" id="department" name="department">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>工号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.JobNumber" placeholder="" id="jobNumber" name="jobNumber">
            </div>
        </div>
               <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">IC卡号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.IcCode" placeholder="请用卡滴一下自动输入" id="icCode" name="icCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">上级菜单：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" id="roleId" name="roleId">
                        @foreach (var item in Model.List)
                        {
                            if (Model.Js_RoleID == item.Js_Id)
                            {
                                <option value="@item.Js_Id" selected>@item.FullName</option>
                            }
                            else
                            {
                                <option value="@item.Js_Id">@item.FullName</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" onclick="operateFunction();" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
        <div class="row cl" style="font-size:12px;">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>说明：</label>
            <div class="formControls col-xs-8 col-sm-9">
                新用户默认密码设置为：123456
            </div>
        </div>
    </form>

</article>

@section javascript {
<script type="text/javascript">
        function operateFunction(){
        var userName=$("#userName").val();
        if(userName==null||userName=="")
        {
           popupAlert('用户名不能为空',2,function(data){layer.close(data);});
          return;
        }
        var fullName=$("#fullName").val();
        if(fullName==null||fullName=="")
        {
           popupAlert('姓名不能为空',2,function(data){layer.close(data);});
          return;
        }
        var department=$("#department").val();
        if(department==null||department=="")
        {
           popupAlert('部门不能为空',2,function(data){layer.close(data);});
          return;
        }
        var jobNumber=$("#jobNumber").val();
        if(jobNumber==null||jobNumber=="")
        {
           popupAlert('工号不能为空',2,function(data){layer.close(data);});
          return;
        }
       SubmitFormForAjax("/admin/operateuser", $("#form-add").serialize(), function (data) {
           if (data.result) {
                   popupAlert('提交成功',1,function(){closePageLayer(true);});
           }else{
               popupAlert(data.message,2,function(data){layer.close(data);});
           }
       },true);
    }
</script>
}
